// 引入路由组件
//import Home from "@/pages/Home"
import Search from "@/pages/Search"
import Login from "@/pages/Login"
import Register from "@/pages/Register"
import Detail from "@/pages/Detail"
import AddCartSuccess from "@/pages/AddCartSuccess"
import ShopCart from "@/pages/ShopCart"
import Trade from "@/pages/Trade"
import Pay from "@/pages/Pay"
import PaySuccess from "@/pages/PaySuccess"
import Center from "@/pages/Center"
// 引入二级路由
import MyOrder from "@/pages/Center/myOrder"
import GroupOrder from "@/pages/Center/groupOrder"

// 配置路由
export default [
    // 路由配置
    // {
    //     path: "/home",
    //     component: Home,
    //     meta: { show: true }
    // },
    // 路由懒加载写法
    {
        path: "/home",
        component: () => import('@/pages/Home'),
        meta: { show: true }
    },
    {
        name: "search",
        path: "/search/:keyword?",
        component: Search,
        meta: { show: true }
    },
    {
        path: "/login",
        component: Login,
        meta: { show: false }
    },
    {
        path: "/register",
        component: Register,
        meta: { show: false }
    },
    {
        path: "/Detail/:skuid",
        component: Detail,
        meta: { show: false }
    },
    {
        name: "addcartsuccess",
        path: "/AddCartSuccess",
        component: AddCartSuccess,
        meta: { show: false }
    },
    {
        path: "/ShopCart",
        component: ShopCart,
        meta: { show: false }
    },
    {
        path: "/Trade",
        component: Trade,
        meta: { show: false },
        // 路由独享守卫
        beforeEnter: (to, from, next) => {
            if (from.path == "/shopcart") {
                next();
            } else {
                next(false);
            }
        }
    },
    {
        path: "/Pay",
        component: Pay,
        meta: { show: false },
        beforeEnter: (to, from, next) => {
            if (from.path == "/trade") {
                next();
            } else {
                next(false);
            }
        }
    },
    {
        path: "/PaySuccess",
        component: PaySuccess,
        meta: { show: false },
        beforeEnter: (to, from, next) => {
            if (from.path == "/pay") {
                next();
            } else {
                next(false);
            }
        }
    },
    {
        path: "/Center",
        component: Center,
        meta: { show: false },
        // 二级路由
        children: [
            {
                path: "myOrder",
                component: MyOrder
            },
            {
                path: "groupOrder",
                component: GroupOrder
            }, {
                path: "/center",
                redirect: "/center/myOrder"
            }
        ]
    },
    {
        path: "*",
        redirect: "/home"
    }
]